﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CUIT.GraduationProject.ToolBoxSystem.PropertyLib
{
    public partial class PropertyLibUsersControl : UserControl
    {
        public delegate void KeyDownEnty(ControlProperty pro);
        public event KeyDownEnty PropertyKeyDownEnter;
        private ControlProperty ctr;
        public ControlProperty Ctr
        {
            get { return ctr; }
            set { ctr = value; }
        }

        /// <summary>
        ///  构造器
        /// </summary>
        public PropertyLibUsersControl()
        {
            InitializeComponent();
            this.propertyGrid_Pro.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid_Pro_PropertyValueChanged);
        }

        void propertyGrid_Pro_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            WaitEnter();
        }

        private void From_KeyDowy(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                WaitEnter();
            }
        }

        /// <summary>
        ///  加载
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private void PropertyLibUsersControl_Load(object sender, EventArgs e)
        {
            propertyGrid_Pro.SelectedObject = ctr;
        }

        public void WaitEnter()
        {
            PropertyKeyDownEnter((ControlProperty)this.propertyGrid_Pro.SelectedObject);
        }

        /// <summary>
        ///  设置大小
        /// </summary>
        /// <param name="size">大小</param>
        public void SetSize(Size size)
        {
            this.Size = size;
        }

        /// <summary>
        ///  时间戳
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private void timerRollUp_Tick(object sender, EventArgs e)
        {
            ////Timer newTimer = new Timer();
            ////newTimer.Interval = 200;
            ////newTimer.Tick += new EventHandler(this.newTimerTick);
            ////newTimer.Start();
            ////timerRollUp.Enabled = false;
        }

        /// <summary>
        ///  新的时间戳
        /// </summary>
        /// <param name="o">对象来源</param>
        /// <param name="e">参数</param>
        private void newTimerTick(Object o, EventArgs e)
        {
            ////Size sz = this.Size;
            ////if (sz.Width > 26)
            ////{
            ////    sz.Width += -20;
            ////}

            ////this.Size = sz;
        }

        /// <summary>
        ///  重绘
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private void splitterHide_Paint(object sender, PaintEventArgs e)
        {
            ////int y = e.ClipRectangle.Bottom;
            ////int top = e.ClipRectangle.Top;

            ////e.Graphics.DrawLine(Pens.LightGray, new Point(0, top), new Point(0, y));
            ////e.Graphics.DrawLine(Pens.DarkGray, new Point(1, top), new Point(1, y));
            ////e.Graphics.DrawLine(Pens.Black, new Point(2, top), new Point(2, y));
            ////e.Graphics.DrawLine(Pens.Black, new Point(3, top), new Point(3, y));

        }

        private void splitterHide_MouseDown(object sender, MouseEventArgs e)
        {

        }

        private void splitterHide_MouseMove(object sender, MouseEventArgs e)
        {

        }

    }
}
